import {createNamespace} from '../utils';

var _createNamespace = createNamespace('row'),
    createComponent = _createNamespace[0],
    bem = _createNamespace[1];

export default createComponent({
    props: {
        type: String,
        align: String,
        justify: String,
        tag: {
            type: String,
            default: 'div'
        },
        gutter: {
            type: [Number, String],
            default: 0
        }
    },
    methods: {
        onClick: function onClick(event) {
            this.$emit('click', event);
        }
    },
    render: function render() {
        var _bem;

        var h = arguments[0];
        var align = this.align,
            justify = this.justify;
        var flex = this.type === 'flex';
        var margin = "-" + Number(this.gutter) / 2 + "px";
        var style = this.gutter ? {
            marginLeft: margin,
            marginRight: margin
        } : {};
        return h(this.tag, {
            "style": style,
            "class": bem((_bem = {
                flex: flex
            }, _bem["align-" + align] = flex && align, _bem["justify-" + justify] = flex && justify, _bem)),
            "on": {
                "click": this.onClick
            }
        }, [this.slots()]);
    }
});